<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>移动定位居中</title>
    <style>
       .wai {
         width: 500px;
         height: 500px;
         background-color: red;
         position: relative;
       }
       .nei {
         width: 200px;
         height: 200px;
         background-color: blue;
         position: absolute;
         left: 50%;
         top: 50%;
         margin-left: -100px;
         margin-top: -100px;
       }
    </style>
</head>
<body>
    <div class="wai">
       <div class="nei"></div>
    </div>
</body>
</html>